package be.kul.osgi.ds.messageservice;

import be.kul.osgi.ds.xmlstreamservice.XMLStreamService;

public class MessageService {

	private XMLStreamService XMLStreamservice;
	//private CommunicationInterface commservice;
	
	public MessageService(){
		
	}
	
	public MessageObject getMessageObject(int perf)
	{
		return new MessageObject(perf);
	}
	
	public String serialize(MessageObject ms)
	{
		String s = new String(XMLStreamservice.toXML(ms));
		return s;
	}
	
	public void send(MessageObject ms)
	{
		
	}
	
	public MessageObject deserialize(String s)
	{
		return null;
	}
	
	/*
	 * COMMUNICATION INTERFACE - UDP in this case
	 */
	
//	public synchronized void setComm(CommunicationInterface commservice) {
//		System.out.println("Communicationcomponent was set. Thank you DS!");
//		this.commservice = commservice;
//	}
//
//	// Method will be used by DS to unset the quote service
//	public synchronized void unsetComm(CommunicationInterface commservice) {
//		System.out.println("Communicationcomponent was unset. Why did you do this to me?");
//		if (this.commservice == commservice) {
//			this.commservice = null;
//		}
//	}
//	
	/*
	 * XMLSTREAMSERVICE
	 */
	public void setXMLStreamService(XMLStreamService service){
		System.out.println("Messagecomponent was set. Thank you DS!");
		this.XMLStreamservice = service;		
	}
	
	public void unsetXMLStreamService(XMLStreamService service){
		System.out.println("XMLServicecomponent was unset. Why did you do this to me?");
		if (this.XMLStreamservice == service) {
			this.XMLStreamservice = null;
		}		
	}
	
	public void Send(MessageObject mes, String receivers){
		//
	}
	
	public void SendMulticast(MessageObject mes, String group){
		
	}
	
}